<template>
  <view class="page">
    <view class=""> </view>
    <view class="header justify-between align-center">
      <view class="justify-between align-center" v-if="article_info">
        <image class="goodImg" mode="aspectFill" :src="article_info.img" />
        <view class="goodTitle">
          {{ article_info.title }}
        </view>
      </view>
    </view>

    <view class="commentlist">
      <view class="commentItem" v-for="(item, index) in comment_list" :key="index">
        <view class="align-center">
          <image class="avatarImg" :src="item.avatar" mode="aspectFill" />
          <view class="nickname">{{ item.nickname }}</view>

          <view class="buyname" :class="{ buyUser: item.ttp == '卖家' }">{{ item.ttp }}</view>
        </view>

        <view class="commentContent">{{ item.content }}</view>
        <view class="commentTime">
          {{ item.create_at }} <text style="margin-left: 20px">{{ item.areaname }}</text>
        </view>
      </view>
    </view>
    <!--  -->
    <view class="again" @click="$to('/pages/evaluate/index?goodId=' + article_info.article_id)" v-if="status == 1">追加评论</view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      id: '',
      comment_list: [],
      article_info: {},
      status: 0
    }
  },
  onLoad(opt) {
    this.id = opt.id
    this.init()
  },
  methods: {
    init() {
      this.$http({ url: 'getComment', data: { article_id: this.id } }).then(res => {
        this.comment_list = res.data.res.data
        this.status = res.data.status
        // 加了一个status 1.显示  0.不显示   数据放在data下的res 中
        if (this.comment_list.length > 0) {
          this.article_info = this.comment_list[0].article_info
          let arr = this.article_info.url.split(',')
          arr.some(item => {
            if (!item.endsWith('.mp4')) {
              this.article_info.img = item
              return true
            }
          })
          this.article_info.article_id = this.comment_list[0].article_id
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
@import '../common/common.css';
.buyname {
  background: #fff0e8;
  border-radius: 2px;

  font-weight: 400;
  font-size: 10px;
  color: #ed6114;
  line-height: 14px;
  text-align: center;
  padding: 2px 5px;
}
.buyUser {
  background: #e7fafd;
  color: #14b8fc;
}
.nickname {
  font-weight: 400;
  font-size: 14px;
  color: #999999;
  line-height: 20px;
  margin-right: 20px;
}
.commentItem {
  width: 95%;
  margin: 10px auto;
  border-bottom: 1px solid #eeeeee;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.header {
  background: #f8f8f8;
  box-sizing: border-box;
  padding: 20px 10px;
  width: 100%;
  .goodImg {
    width: 110rpx;
    height: 110rpx;
    border-radius: 10px;
    display: block;
    margin-right: 10px;
  }

  .goodTitle {
    color: rgba(51, 51, 51, 1);
    font-size: 26rpx;
    width: 300px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
}
.page {
  background-color: rgba(255, 255, 255, 1);
  width: 100%;
  height: 100vh;
  overflow-y: scroll;
  padding-bottom: 70px;
  .commentlist {
    background: #fff;
  }

  .commentTime {
    font-weight: 400;
    font-size: 11px;
    color: #a8a8a8;
  }
  .commentContent {
    height: 18px;
    font-weight: 400;
    font-size: 13px;
    color: #333333;
    line-height: 18px;
    margin: 10px 0;
  }
  .avatarImg {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 15px;
  }
}
.again {
  width: 335px;
  height: 44px;
  background: linear-gradient(331deg, #fe373c 0%, #fe7837 100%);
  box-shadow: 0px 2px 6px 0px rgba(255, 136, 139, 0.5);
  border-radius: 22px;
  text-align: center;
  font-weight: 500;
  font-size: 15px;
  color: #ffffff;
  line-height: 44px;
  margin: 0 auto;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 5%;
}
</style>
